
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <link rel="stylesheet" href="https://static.9hive.cn/global/vendor/common/common_20170925.css">
    <link rel="stylesheet" href="https://static.9hive.cn/hive/assets/css/importexcel.css">
    <link rel="stylesheet" href="https://static.9hive.cn/global/iconhive/hiveicon.css">
    <!--[if lt IE 9]>
    <script src="https://static.9hive.cn/global/vendor/html5shiv/html5shiv.min.js"></script>
    <![endif]-->

    <!--[if lt IE 10]>
    <script src="https://static.9hive.cn/global/vendor/media-match/media.match.min.js"></script>
    <script src="https://static.9hive.cn/global/vendor/respond/respond.min.js"></script>
    <![endif]-->
</head>
<body class="iframe-body">
<div class="flexed content_center content_alignCenter relative_position" style="transform: translateY(40%);">
    <button style="display: none;" type="button" id="button" class="btn btn-outline btn-default">
        <i class="glyphicon" aria-hidden="true"></i>选择
    </button>
    <div style="padding: 20px 20px 20px 40px;">
        <img src="https://static.9hive.cn/global/img/excel.png">
    </div>
    <div style="padding-right: 36px; line-height: 28px;">
        <span>为确保上传数据的完整性，请先<a onclick="downloadTemplate()" class="link_a" style="text-decoration: underline!important;">下载模板</a>编辑模板后再上传模板文件</span>
    </div>

    <input type ="file" id="importData" name="memberFile" style="display: none"/>

</div>

<script src="https://static.9hive.cn/global/vendor/jquery/jquery-2.1.4.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/layer/layer.js"></script>
<script src="/res/js/ajaxfileupload.js"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name);
    function downloadTemplate() {
        location.href = '/shop/brandmember/brandMemberDemo'
    }

    $('#button').on('click', function () {
        $('#importData').click();
    });

    //选择文件之后执行上传
    $('#importData').on('change', function () {
        var iframeWin = window.parent.document.getElementById("mainFrame");
        var Win = iframeWin.contentWindow;
        $.ajaxFileUpload({
            url: "/shop/brandmember/importBrandMemberData",
            type: "POST",
            secureuri: false,
            fileElementId: 'importData',//file标签的id
            dataType: 'json',//返回数据的类型
            data: {},//一同上传的数据
            success: function (data) {
                if (data.state=="ok" == true) {
                    parent.layer.msg("导入成功!");
                    Win.refresh_table1();
                }else{
                    parent.layer.msg(data.info);
                }
                parent.layer.close(index);
            }
        });
    });
</script>
</body>
</html>